#!/bin/bash

#########################
# FunFile Status Getter #
##### By: an0n0m0us #####

# Variably necessary variables.
COOKIE=funfile.org.cookie
TMP_FILE=index.php.tmp

# Function junction.
display_status() {
clean_credits=`awk '/mycredits\.php/' $TMP_FILE|sed -e 's/<[^>]*>//g'`
clean_totals=`awk /^Total/ $TMP_FILE|sed -e 's/<[^>]*>//g'`
echo -e "\n$clean_credits\n$clean_totals\n"
}

# cooooOOOOOOOOooookies!
if [[ ! -e "$COOKIE" ]];then
        read -p "Username: " USER
        stty -echo
        read -p "Password: " PASS;echo
        stty echo
 curl -Lskc $COOKIE -d "returnto=/&username=${USER}&password=${PASS}&login=Login" -o $TMP_FILE https://www.funfile.org/takelogin.php
 display_status
else
 curl -Lskb $COOKIE -o $TMP_FILE https://www.funfile.org/index.php
 display_status
fi

# Clean up house and gtfo.
rm -f $TMP_FILE && exit 0
